WINAMPCALL.PAS

unit WinampCall;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TWinampCall = class(Tcomponent)
  private
    { Private declarations }
    hwnd_winamp : THandle;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Procedure Previous;
    Procedure Play;
    Procedure Pause;
    Procedure Stop;
    Procedure Next;
    Procedure Hide;
    Procedure Show;
  end;

procedure Register;

implementation

const
  WinampClassName = 'winamp v1.x';
  IPC_STARTPLAY = 102;
  WINAMP_BUTTON1 = 40044;
  WINAMP_BUTTON2 = 40045;
  WINAMP_BUTTON3 = 40046;
  WINAMP_BUTTON4 = 40047;
  WINAMP_BUTTON5 = 40048;

Procedure TWinampCall.Play;
begin
  hwnd_winamp := FindWindow(WinampClassName,nil);
  sendMessage(hwnd_winamp,WM_USER,0,IPC_STARTPLAY);
end;

Procedure TWinampCall.Previous;
begin
  hwnd_winamp := FindWindow(WinampClassName,nil);
  SendMessage(hwnd_winamp,WM_COMMAND,WINAMP_BUTTON1,0);
end;

Procedure TWinampCall.Next;
begin
  hwnd_winamp := FindWindow(WinampClassName,nil);
  SendMessage(hwnd_winamp,WM_COMMAND,WINAMP_BUTTON5,0);
end;

Procedure TWinampCall.Pause;
begin
  hwnd_winamp := FindWindow(WinampClassName,nil);
  SendMessage(hwnd_winamp,WM_COMMAND,WINAMP_BUTTON3,0);
end;

Procedure TWinampCall.Stop;
begin
  hwnd_winamp := FindWindow(WinampClassName,nil);
  SendMessage(hwnd_winamp,WM_COMMAND,WINAMP_BUTTON4,0);
end;

Procedure TWinampCall.Hide;
var
  WP : TWindowPlaceMent;
begin
  hwnd_winamp := FindWindow(WinampClassName,nil);
  wp.length := SizeOf(TWindowPlaceMent);
  wp.showCmd := SW_HIDE;
  SetWindowPlacement(hwnd_winamp,@wp);
end;

Procedure TWinampCall.Show;
var
  WP : TWindowPlaceMent;
begin
  hwnd_winamp := FindWindow(WinampClassName,nil);
  wp.length := SizeOf(TWindowPlaceMent);
  wp.showCmd := SW_SHOW;
  SetWindowPlacement(hwnd_winamp,@wp);
end;


procedure Register;
begin
  RegisterComponents('Freeware', [TWinampCall]);
end;

end.

Copyright 1998 Rob Vonk